﻿using Autofac;
using Bll;
using Bll.User;
using Dao;
using Infrastructure.Model;
using Microsoft.AspNetCore.Hosting;

namespace ApiApp
{
    public class AutofacRegisterModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            ////获取所有控制器类型并使用属性注入
            //Type[] controllersTypeAssembly = typeof(Startup).Assembly.GetExportedTypes()
            //    .Where(type => typeof(ControllerBase).IsAssignableFrom(type)).ToArray();
            //builder.RegisterTypes(controllersTypeAssembly).PropertiesAutowired();

            //批量自动注入,把需要注入层的程序集传参数
            AutofacIocManger.BatchAutowired(builder, typeof(DBConfig).Assembly, typeof(UserAccountBll).Assembly, typeof(AutofacRegisterModule).Assembly);
            //builder.BatchAutowired(typeof(UserService).Assembly);
            // builder.BatchAutowired(typeof(UserRepository).Assembly);
        }
    }
}
